// js/lightbox.js
document.addEventListener("DOMContentLoaded", function () {
  const triggers = document.querySelectorAll(".lightbox-trigger");
  const modal = document.getElementById("lightbox-modal");
  const modalImg = document.querySelector(".lightbox-img");
  const captionText = document.querySelector(".lightbox-caption");
  const closeBtn = document.querySelector(".lightbox-close");

  triggers.forEach(trigger => {
    trigger.addEventListener("click", function () {
      modal.style.display = "block";
      modalImg.src = this.src;
      captionText.innerHTML = this.getAttribute("data-caption");
    });
  });

  closeBtn.addEventListener("click", function () {
    modal.style.display = "none";
  });

  window.addEventListener("click", function (e) {
    if (e.target === modal) {
      modal.style.display = "none";
    }
  });
});